/*
 * @Author: your name
 * @Date: 2022-02-17 16:29:18
 * @LastEditTime: 2022-02-17 17:08:41
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geek-app\src\store\reducer\channel.js
 */

import { CHANNEL_SAVE_LIST, CHANNEL_SAVE_CURRENT } from '../action/actionType';
const initialState = {
  list: [],
  current: 0,
};

export default function channelReducer(
  state = initialState,
  { type, payload }
) {
  switch (type) {
    case CHANNEL_SAVE_LIST:
      return {
        ...state,
        list: [...payload],
      };

    // 定义更新的逻辑分支
    case CHANNEL_SAVE_CURRENT:
      return {
        ...state,
        // 更新current的值
        current: payload,
      };
    default:
      return state;
  }
}
